const express = require("express");
const router = express.Router(); // 创建服务器的实例对象
const user_handler = require("../router_handler/user"); // 导入处理函数模块
const expressJoi = require("@escook/express-joi"); // 导入验证数据的中间件

const {
  reg_schema,
  login_schema,
  update_pwd_schema,
} = require("../schema/user"); // 导入验证规则对象

router.post("/reguser", expressJoi(reg_schema), user_handler.regUser); // 注册
router.post("/login", expressJoi(login_schema), user_handler.login); // 登录
router.post("/logout", user_handler.logout); // 注销
router.post(
  "/updatedPwd",
  expressJoi(update_pwd_schema),
  user_handler.updatePassword
); // 重置密码

router.get("/email", user_handler.getEmailCaptcha); // 邮箱验证码获取
router.post("/emaillogin", user_handler.emailLogin); // 邮箱登录
module.exports = router;
